home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak Vol E-12
/
(Vol E-12) May 21 2012.iso
/
Animations
/
dj
/
dj.swf
/
scripts
/
__Packages
/
mx
/
controls
/
Loader.as
< prev
next >
Wrap
Text File
|
2012-05-21
|
7KB
|
278 lines
class mx.controls.Loader extends mx.core.View
{
static var symbolName = "Loader";
static var symbolOwner = mx.controls.Loader;
static var version = "2.0.1.78";
var className = "Loader";
var clipParameters = {autoLoad:1,scaleContent:1,contentPath:1};
static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.Loader.prototype.clipParameters,mx.core.View.prototype.clipParameters);
var __autoLoad = true;
var __bytesLoaded = undefined;
var __bytesTotal = undefined;
var __contentPath = undefined;
var __scaleContent = true;
function Loader()
{
super();
}
function init()
{
super.init();
}
function setSize(w, h, noEvent)
{
this._origWidth = w;
this._origHeight = h;
super.setSize(w,h,noEvent);
if(_global.isLivePreview)
{
this.livePreview._width = this.__width - 1;
this.livePreview._height = this.__height - 1;
}
}
function draw()
{
this.size();
}
function size()
{
super.size();
if(this.__scaleContent)
{
this.doScaleContent();
}
else
{
this.doScaleLoader();
}
}
function createChildren()
{
super.createChildren();
if(_global.isLivePreview)
{
this.createTextField("livePreview",-1000,0,0,99,99);
this.livePreview.text = "mx.controls.Loader";
this.livePreview.border = true;
}
if(this.__autoLoad)
{
this.load();
}
}
function getAutoLoad()
{
return this.__autoLoad;
}
function get autoLoad()
{
return this.getAutoLoad();
}
function setAutoLoad(b)
{
if(this.__autoLoad != b)
{
this.__autoLoad = b;
if(this.__autoLoad && !this[mx.core.View.childNameBase + 0]._complete)
{
this.load();
}
}
}
function set autoLoad(b)
{
this.setAutoLoad(b);
}
function getBytesLoaded()
{
return this.__bytesLoaded;
}
function get bytesLoaded()
{
return this.getBytesLoaded();
}
function getBytesTotal()
{
return this.__bytesTotal;
}
function get bytesTotal()
{
return this.getBytesTotal();
}
function getContent()
{
return this.contentHolder;
}
function get content()
{
return this.getContent();
}
function getContentPath()
{
return this.__contentPath;
}
function get contentPath()
{
return this.getContentPath();
}
function setContentPath(url)
{
if(this.__contentPath != url)
{
this.__contentPath = url;
if(this.childrenCreated)
{
if(this.__autoLoad)
{
this.load();
}
}
}
}
function set contentPath(c)
{
this.setContentPath(c);
}
function getPercentLoaded()
{
var _loc2_ = 100 * (this.__bytesLoaded / this.__bytesTotal);
if(isNaN(_loc2_))
{
_loc2_ = 0;
}
return _loc2_;
}
function get percentLoaded()
{
return this.getPercentLoaded();
}
function get scaleContent()
{
return this.getScaleContent();
}
function getScaleContent()
{
return this.__scaleContent;
}
function setScaleContent(b)
{
if(this.__scaleContent != b)
{
this.__scaleContent = b;
if(this.__scaleContent)
{
this.doScaleContent();
}
else
{
this.doScaleLoader();
}
}
}
function set scaleContent(b)
{
this.setScaleContent(b);
}
function load(url)
{
if(url != undefined)
{
this.__contentPath = url;
}
if(this[mx.core.View.childNameBase + 0] != undefined)
{
if(this[mx.core.View.childNameBase + 0]._complete)
{
this.setSize(this._origWidth,this._origHeight);
}
this.destroyChildAt(0);
}
if(this.__contentPath == undefined || this.__contentPath == "")
{
return undefined;
}
this.createChild(this.__contentPath,"contentHolder");
}
function childLoaded(obj)
{
super.childLoaded(obj);
obj._rotation = 0;
this._origWidth = this.__width;
this._origHeight = this.__height;
if(this.__scaleContent)
{
this.doScaleContent();
}
else
{
this.doScaleLoader();
}
}
function dispatchEvent(obj)
{
if(obj.type == "progress" || obj.type == "complete")
{
obj.target = this;
this.__bytesTotal = obj.total;
this.__bytesLoaded = obj.current;
}
super.dispatchEvent(obj);
}
function doScaleContent()
{
if(!this[mx.core.View.childNameBase + 0]._complete)
{
return undefined;
}
this.unScaleContent();
var _loc2_ = this.border_mc.__get__borderMetrics();
var _loc7_ = this._origWidth - _loc2_.left - _loc2_.right;
var _loc6_ = this._origHeight - _loc2_.top - _loc2_.bottom;
var _loc9_ = _loc2_.left;
var _loc8_ = _loc2_.top;
var _loc5_ = _loc7_ / this.contentHolder._width;
var _loc3_ = _loc6_ / this.contentHolder._height;
var _loc4_ = undefined;
if(_loc5_ > _loc3_)
{
_loc9_ = _loc2_.left + Math.floor((_loc7_ - this.contentHolder._width * _loc3_) / 2);
_loc4_ = _loc3_;
}
else
{
_loc8_ = _loc2_.top + Math.floor((_loc6_ - this.contentHolder._height * _loc5_) / 2);
_loc4_ = _loc5_;
}
_loc4_ *= 100;
this.contentHolder._xscale = this.contentHolder._yscale = _loc4_;
this.contentHolder._x = _loc9_;
this.contentHolder._y = _loc8_;
if(this.__width != this._origWidth || this.__height != this._origHeight)
{
this.setSize(this._origWidth,this._origHeight);
}
}
function doScaleLoader()
{
if(!this[mx.core.View.childNameBase + 0]._complete)
{
return undefined;
}
this.unScaleContent();
var _loc2_ = this.border_mc.__get__borderMetrics();
var _loc4_ = this.contentHolder._width + _loc2_.left + _loc2_.right;
var _loc3_ = this.contentHolder._height + _loc2_.top + _loc2_.bottom;
if(this.__width != _loc4_ || this.__height != _loc3_)
{
this.setSize(_loc4_,_loc3_);
}
this.contentHolder._x = _loc2_.left;
this.contentHolder._y = _loc2_.top;
}
function unScaleContent()
{
this.contentHolder._xscale = this.contentHolder._yscale = 100;
this.contentHolder._x = this.contentHolder._y = 0;
}
}